/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package tests;

/**
 *
 * @author luis
 */
public class cadenas {
    String cadena;
    cadenas(){
        System.out.println("Introduce la cadena: ");
        cadena = Scan.Console.nextLine();
    }

    /**
     *
     */
    public void mitad(){
        System.out.println(cadena.substring(0, cadena.length()/2));
    }

    /**
     *
     */
    public void last(){
        System.out.println(cadena.charAt(cadena.length()-1));
    }

    /**
     *
     */
    public void reves(){
        for (int i = cadena.length()-1; i >= 0; i--) {
            System.out.print(cadena.charAt(i));
        }
        System.out.print("\n");
    }

    /**
     *
     */
    public void guion(){
        for (int i = 0; i < cadena.length(); i++) {
            if(i == cadena.length()-1){
                System.out.println(cadena.charAt(i));
                continue;
            }
            System.out.print(cadena.charAt(i) + "-");
        }
    }

    /**
     *
     */
    public void vocales(){
        int contador = 0;
        char a;
        for (int i = 0; i < cadena.length(); i++) {
            a = cadena.charAt(i);
            if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u') contador++;
        }
        System.out.println("vocales: " + contador);
    }

    /**
     *
     */
    public void palindromo(){
        String cadena2 = "";
        for (int i = cadena.length()-1; i >= 0; i--) {
            cadena2 += cadena.charAt(i);
        }
        if(cadena.equals(cadena2)){
            System.out.println("es palindromo");
        }
        
    }

    /**
     *
     * @param args
     */
    public static void main(String[] args) {
        cadenas cadena1 = new cadenas();
        cadena1.mitad();
        cadena1.last();
        cadena1.reves();
        cadena1.guion();
        cadena1.vocales();
        cadena1.palindromo();
    }
}
